/**
 * 
 *  @project Air Traff Monitor
 * 
 *  @author M.Emre ATASEVER <m.emre.atas@gmail.com>
 *  @author M.Burak ALKAN <mburakalkan@gmail.com>
 *  @author H.Burak KARAMIK <bkaramik@gmail.com>
 *
 *	`Air Traffic Monitor' is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef KISOCK_H
#define KISOCK_H

#include <QTcpSocket>
#include <QTextStream>
#include <QVariant>
#include <QStringList>
#include "protprops.h"

struct kismetInfo{
	QString version, name, build;
	int stime;
};
struct networkInfo{
	QList<QVariant> props;
	const QList<int> *idx;
};

#define alertInfo networkInfo
#define clientInfo networkInfo
#define iInfo networkInfo
#define cardInfo networkInfo

class QKismetSocket : public QTcpSocket
{
	Q_OBJECT
public:
	QKismetSocket();

	static int readValue(int i,QByteArray data,QVariant *out);
	NetworkOptions net;
	AlertOptions alert;
	InfoOptions info;
	CardOptions card;
	ClientOptions client;
public slots:
	void Disconnect();
	void Connect(QString host="127.0.0.1", int port=2501);
	void Pause();
	void Resume();
	void SetNetOption(QString opt,bool enable);
	void SetClientOption(QString opt,bool enable);
	void SetAlertOption(QString opt,bool enable);
	void SaveSettings();
signals:
	void serverTime(int time);
	void serverInfo(kismetInfo info);
	void netInfo(networkInfo info);
	void alInfo(alertInfo info);
	void infoInfo(iInfo info);
	void cliInfo(clientInfo info);
	void crdInfo(cardInfo info);
	void statInfo(QString s);
	void stateCh(QAbstractSocket::SocketState);
private:
	int id;
private slots:
	void Read();
	void SetOptions();
};

#endif
